package com.zcx.qshop.conn;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;


@HttpInlet(Conn.INLET_JSON_EVALUATELIST)
public class JsonEvaluatelistAsyGet extends QSAsyGet<JsonEvaluatelistAsyGet.Info> {
	
	public String gid;
 
	public JsonEvaluatelistAsyGet(String gid, AsyCallBack<Info> asyCallBack) {
		
		super(asyCallBack);
		
		this.gid = gid;
		
 	}
	
	@Override
	public Info parser(JSONObject object) { 
		
		if(object.optString("message").equals("1")){
			
			Info info = new Info();
			
			JSONArray array = object.optJSONArray("evaluatelist");
			
			for (int i = 0; i < array.length(); i++) {
				
				Info.Evaluate evaluate = new Info.Evaluate();
				
				JSONObject o = array.optJSONObject(i);
				
				evaluate.picurl = Conn.SERVICE + o.optString("picurl");
				
				evaluate.name = o.optString("name");
				
				evaluate.start = o.optString("start");
				
				evaluate.info = o.optString("info");

				evaluate.recontent = o.optString("recontent");
				
				info.evaluates.add(evaluate);
				
			}
			
			return info;
			
		}
		
		return super.parser(object);
	}

	public static class Info{
		
		public List<Evaluate> evaluates = new ArrayList<Evaluate>(); 
		
		public static class Evaluate{
			
			public String picurl, name, start, info, recontent;
			
		}
		
	}

}
